﻿using System;

namespace 角谷猜想
{
	class Program
	{
		static void Main(string[] args)
		{
			//for (int n = 0; n <=100; n++)
			//{
			//	int a = n;
			//	while (a!=1)
			//	{
			//		Console.Write(" " + a);
			//		if (a % 2 == 1)
			//			a = a * 3 + 1;
			//		else
			//			a /= 2;
			//	}
			//	Console.WriteLine(" " + a);
			//}


			Console.WriteLine("请输入一个大于1的正整数!");
			string aStrInput = Console.ReadLine();
			int aIntInput;
			bool aAgain = true;
			while (aAgain)
			{
				while (!int.TryParse(aStrInput, out aIntInput) || aIntInput <= 1)
				{
					Console.WriteLine("请输入一个大于1的正整数!");
					aStrInput = Console.ReadLine();
				}
				int aIntOutput = aIntInput;
				while (aIntOutput != 1)
				{
					if (aIntOutput % 2 == 0)
					{
						aIntOutput /= 2;
					}
					else
					{
						aIntOutput = aIntOutput * 3 + 1;
					}
					Console.WriteLine(aIntOutput.ToString());
				}
				Console.WriteLine("按数字0退出系统，按数字1重试");
				aStrInput = Console.ReadLine();
				while (!int.TryParse(aStrInput, out aIntInput) || (aIntInput != 0 && aIntInput != 1))
				{
					Console.WriteLine("请输入正确的命令!");
					aStrInput = Console.ReadLine();
				}
				aAgain = aIntInput == 0 ? false : true;
			}
		}
	}
}
